//initialize the array of var originalValue = new Array(); var clickCounterOnImage = 0; // Get all values from every input-tag $('input').each(function() { if($(this).attr('type') != 'submit'){ originalValue.push($(this).val()); $(this).addClass("gray"); } }); // ONCLICK, check if value is the original. If so, change value of input to ''. If not, leave it (since that is the users own input) $('input').focus(function() { if($(this).attr('type') != 'submit'){ if($(this).val() == originalValue[$('input').index(this)]){ $(this).val(""); $(this).removeClass("gray"); } } }); // FOCUSOUT, check if value is zero. If so, replace with the original. $('input').focusout(function() { if($(this).attr('type') != 'submit'){ if($(this).val() == ""){ $(this).val( originalValue[$('input').index(this)] ); $(this).addClass("gray"); $(this).css("border: 5px solid lawnGreen;"); } } });